﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MinistryStandardPlatformWeb;
using MinistryStandardPlatformEntity;

namespace MinistryStandardPlatformWeb.Controllers
{
    [MenuAuthorized("3",Order=1)]
    [IsLogin(Order=0)]
    public class OperationManageController : Controller
    {
        //
        // GET: /OperationManage/
        private MSPDataContext context = new MSPDataContext();

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Tree()
        {
            var units = context.RightsDetails.Where(u => u.UserId == CommonFunctions.GetLoginUser().UserId && u.NodeTYPE == true).Select(u => u);
            List<ZTreeNode> nodes = new List<ZTreeNode>();
            foreach (var unit in units)
            {
                ZTreeNode node = new ZTreeNode();
                node.id = unit.NodeId;
                node.pId = unit.ParentNodeId;
                node.name = unit.NodeName;
                node.icon = "/Content/themes/zTreeStyle/img/diy/1_open.png";
                if (unit.ParentNodeId == null)
                {
                    node.open = true;
                }
                else
                {
                    node.open = false;
                }
                nodes.Add(node);
            }
            ViewBag.nodesJson = CommonFunctions.ListToJsonStr<ZTreeNode>(nodes);
            return PartialView();
        }
    }
}
